package exercise8;

import java.io.*;

public class Exercise17_07 {
    public static void main(String []args) throws IOException {
        ObjectInputStream inputStream=new ObjectInputStream(new FileInputStream("Exercise17_06.dat"));

        //贷款额
        int total=0;
        //类的个数
        int num=0;

        try {
            while (true){
                Loan loan=(Loan)inputStream.readObject();
                num++;
                total+=loan.getLoanAmount();
            }
        } catch (EOFException | ClassNotFoundException e) {
            System.out.println("there are totally "+total);
            System.out.println("there are "+num+" Loans");
        }
    }
}
